<button onclick="sendJson()">发送 JSON 格式 POST 请求</button>
<script>
    function sendJson() {
        ajax({
            url: 'postParameterJson',
            method: 'POST',
            contentType: 'application/json; charset=utf-8',
            body: JSON.stringify({ userId: 123, classId: 456 }),
            callback: function (body, status) {
                console.log(body);
           }
       });
   }

    function ajax(args) {
 // 函数体略.... 参考之前封装的版本.
   }
</script>